<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<div contenteditable="true">foo</div>
<script>
test(() => {
  // Note that this test can be removed when crbug.com/690272 is fixed.
  let selection = getSelection();
  let editor = document.querySelector('div');
  editor.addEventListener('focus', () => { selection.removeAllRanges(); });
  selection.collapse(editor, 0);
  assert_throws_dom('InvalidStateError', () => { selection.extend(editor, 1);});
}, 'Focus event handler should not make inconsistent state of Selection, and extend() should not crash.');
</script>
</body>
